$(function() {
	//点击(移动页面)
	var oldViewId = null,
		newViewId = null,
		judge = false;
	$("li[id^=Src_]").click(function() {
		//(播放完成才会变为true)如果为true的话禁止点击
		if (judge)
			return;

		//开始执行
		judge = true;
		var name = "#" + $(this).attr("id").substring(4);

		if (newViewId != null) {
			oldViewId = newViewId;
		}
		//不是重新点击
		if (name != newViewId) {
			newViewId = name;
			//清除旧页面
			if (oldViewId != null) {
				const {
					tween,
					styler
				} = popmotion;
				const ballStyler = styler(document.querySelector(oldViewId));
				//上滑
				if ($(oldViewId).index() > $(newViewId).index()) {
					tween({
						duration: 1000,
						from: {
							"opacity": 1
						},
						to: {
							"opacity": 0
						}
					}).start(ballStyler.set);
				}
				//下消
				if ($(oldViewId).index() < $(newViewId).index()) {
					tween({
						duration: 1000,
						from: {
							"marginTop": 0
						},
						to: {
							"marginTop": -$(oldViewId).height()
						}
					}).start(ballStyler.set);
				}
				//清除旧窗体
				setTimeout(function() {
					$(oldViewId).css({
						"display": "none"
					});
				}, 1000);
			}

			//给予新窗体准备值
			var height = $(newViewId).height();
			$(newViewId).css({
				"display": "block",
				"height": "0px"
			});

			const {
				tween,
				styler
			} = popmotion;
			const ballStyler = styler(document.querySelector(newViewId));
			//出现动画
			tween({
				duration: 1000,
				from: {
					height: $(newViewId).height(),
					opacity: 1,
					marginTop: 0,
					display: "block"
				},
				to: {
					height: height,
					opacity: 1,
					marginTop: 0,
					display: "block"
				}
			}).start(ballStyler.set);
		}
		//打开点击按钮
		setTimeout(function() {
			judge = false;
		}, 1000);
	})

	//确定高度
	$(window).resize(function() {
		console.log($("#Home02").height())
	})
})
